package com.wind.controller;

import com.wind.common.dto.TestDTO;
import com.wind.common.query.TestQuery;
import com.wind.common.result.R;
import com.wind.common.vo.TestVO;
import com.wind.service.TestService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author FengYin
 * @since 2024/8/29 17:55
 */
@Tag(name = "测试通用接口")
@RestController
@RequestMapping("/common/test")
@AllArgsConstructor
public class TestController {
    private final TestService testService;

    @PostMapping()
    @Operation(summary = "新增测试")
    public R<Void> add(@Valid @RequestBody TestDTO dto) {
        testService.add(dto);
        return R.success();
    }

    @PutMapping()
    @Operation(summary = "修改测试")
    public R<Void> edit(@Valid @RequestBody TestDTO dto) {
        testService.edit(dto);
        return R.success();
    }

    @GetMapping("/list")
    @Operation(summary = "查询测试列表")
    public R<List<TestVO>> list(TestQuery query) {

        return R.success(testService.list(query));
    }

    @GetMapping("/{id}")
    @Operation(summary = "查询测试详情")
    public R<TestVO> info(@PathVariable Long id) {
        return R.success(testService.info(id));
    }
}
